package mhys.View.Teacher;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class NavJpanel extends JPanel {
    public NavJpanel(){
        this.setBackground(new Color(240, 240, 240));
        this.setPreferredSize(new Dimension(200, 0));
        this.setLayout(null);
        this.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 2, new Color(210, 210, 210)));

        JButton stuButton = new JButton("学生列表");
        stuButton.setBackground(new Color(240, 240, 240));
        stuButton.setBorderPainted(false);
        stuButton.setFocusPainted(false);
        stuButton.setFont(new Font("微软雅黑", Font.PLAIN, 18));
        stuButton.setBounds(0, 10, 198, 35);

        JButton addButton = new JButton("学生添加");
        addButton.setBackground(new Color(240, 240, 240));
        addButton.setBorderPainted(false);
        addButton.setFocusPainted(false);
        addButton.setFont(new Font("微软雅黑", Font.PLAIN, 18));
        addButton.setBounds(0, 50, 198, 35);

        JButton classButton = new JButton("班级添加");
        classButton.setBackground(new Color(240, 240, 240));
        classButton.setBorderPainted(false);
        classButton.setFocusPainted(false);
        classButton.setFont(new Font("微软雅黑", Font.PLAIN, 18));
        classButton.setBounds(0, 90, 198, 35);

        JButton scoreButton = new JButton("成绩管理");
        scoreButton.setBackground(new Color(240, 240, 240));
        scoreButton.setBorderPainted(false);
        scoreButton.setFocusPainted(false);
        scoreButton.setFont(new Font("微软雅黑", Font.PLAIN, 18));
        scoreButton.setBounds(0, 130, 198, 35);

        this.add(stuButton);
        this.add(addButton);
        this.add(classButton);
        this.add(scoreButton);

        stuButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                App.jPanel.removeAll();
                StudentPanel studentPanel = new StudentPanel();
                App.jPanel.add(studentPanel);
                App.jPanel.updateUI();
            }
        });

        addButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                App.jPanel.removeAll();
                addStuJpanel addStuJpanel = new addStuJpanel();
                App.jPanel.add(addStuJpanel);
                App.jPanel.updateUI();
            }
        });

        classButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                App.jPanel.removeAll();
                ClassJpanel classJpanel = new ClassJpanel();
                App.jPanel.add(classJpanel);
                App.jPanel.updateUI();
            }
        });

        scoreButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                App.jPanel.removeAll();
                ScoreJpanel scoreJpanel = new ScoreJpanel();
                App.jPanel.add(scoreJpanel);
                App.jPanel.updateUI();
            }
        });

    }
}
